package com.sxsihe.heartmate.view;

import android.app.Activity;
import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.PopupWindow;
import com.sxsihe.heartmate.R;

/**
 * Created by mac on 16/10/22.
 */
public class TimePopupWindow extends PopupWindow {
    private Button btn_1min, btn_3min, btn_no_limit;
    private View mMenuView;

    public TimePopupWindow(Context context,View.OnClickListener itemsOnClick) {
        super(context);
        LayoutInflater inflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        mMenuView = inflater.inflate(R.layout.time_dialog, null);
        btn_1min = (Button) mMenuView.findViewById(R.id.btn_1min);
        btn_3min = (Button) mMenuView.findViewById(R.id.btn_3min);
        btn_no_limit = (Button) mMenuView.findViewById(R.id.btn_no_limit);

        btn_1min.setOnClickListener(itemsOnClick);
        btn_3min.setOnClickListener(itemsOnClick);
        btn_no_limit.setOnClickListener(itemsOnClick);
        this.setContentView(mMenuView);
        this.setWidth(ViewGroup.LayoutParams.FILL_PARENT);
        this.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
        this.setFocusable(true);
        this.setAnimationStyle(R.style.AnimBottom);
        ColorDrawable dw = new ColorDrawable(0xb0000000);
        this.setBackgroundDrawable(dw);
        mMenuView.setOnTouchListener(new View.OnTouchListener() {
            public boolean onTouch(View v, MotionEvent event) {
                dismiss();
                return true;
            }
        });

    }
}
